<template>
  <div>
    <el-form :model="borrower" label-width="100px">
      <el-row :gutter="10">
        <el-col :span="6">
          <el-form-item label="状态">
            {{ borrower.status }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="创建时间">
            {{ borrower.createTime }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="10">
        <el-col :span="6">
          <el-form-item label="姓名">
            {{ borrower.name }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="性别">
            {{ borrower.sex }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="年龄">
            {{ borrower.age }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="手机">
            {{ borrower.sex }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="10">
        <el-col :span="6">
          <el-form-item label="学历">
            {{ borrower.education }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="婚否">
            {{ borrower.marry }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="行业">
            {{ borrower.industry }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="还款来源">
            {{ borrower.returnSource }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="10">
        <el-col :span="6">
          <el-form-item label="身份证">
            {{ borrower.idCard }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="联系人姓名">
            {{ borrower.contactsName }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="联系人手机">
            {{ borrower.contactsMobile }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="联系人关系">
            {{ borrower.contactsRelation }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="10">
        <el-col :span="6">
          <el-form-item label="身份证正面">
            <el-image
              style="width: 100px; height: 100px"
              :src="image.idCard1"
              :fit="fit"
              :previewSrcList='[image.idCard1]'
            ></el-image>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="身份证反面">
            <el-image
              style="width: 100px; height: 100px"
              :src="image.idCard2"
              :fit="fit"
              :previewSrcList='[image.idCard2]'
            ></el-image>
          </el-form-item>
        </el-col>
         <el-col :span="6">
          <el-form-item label="房产信息">
            <el-image
              style="width: 100px; height: 100px"
              :src="image.house"
              :fit="fit"
              :previewSrcList='[image.house]'
            ></el-image>
          </el-form-item>
        </el-col>
         <el-col :span="6">
          <el-form-item label="车辆信息">
            <el-image
              style="width: 100px; height: 100px"
              :src="image.car"
              :fit="fit"
              :previewSrcList='[image.car]'
            ></el-image>
          </el-form-item>
        </el-col>
      </el-row>
     
    </el-form>
    <el-form v-if="borrower.status===1" :model="borrowerApprove" label-width="220px">
        <el-row :gutter="10">
          <el-col :span="12" :offset="6">
            <el-form-item label="是否通过">
              <el-radio-group v-model="borrowerApprove.status">
                <el-radio label="2">是</el-radio>
                <el-radio label="-1">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="6" :offset="6">
            <el-form-item label="基本信息积分">
              <el-input  v-model="borrowerApprove.infoIntegral"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12" :offset="6">
            <el-form-item label="身份证信息是否正确">
              <el-radio-group v-model="borrowerApprove.isIdCardOk">
                <el-radio label="true">是</el-radio>
                <el-radio label="false">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12" :offset="6">
            <el-form-item label="车辆信息是否正确">
              <el-radio-group v-model="borrowerApprove.isCarOk">
                <el-radio label="true">是</el-radio>
                <el-radio label="false">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="12" :offset="6">
            <el-form-item label="房产信息是否正确">
              <el-radio-group v-model="borrowerApprove.isHouseOk">
                <el-radio label="true">是</el-radio>
                <el-radio label="false">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
       <el-col :span="12" :offset="8">
        <el-button type="primary" :disabled="saveBtnDisabled" @click="approveSubmit">确定</el-button>
        <el-button type="primary" @click="$router.push('/core/borrow/list')" plain>返回</el-button>
       </el-col>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      fit:'fill',
      borrower: {},
      saveBtnDisabled: false, //防止重复提交
      image:{
        idCard1:null,
        idCard2:null,
        house:null,
        car:null
      },
      borrowerApprove:{
        
      }
    }
  },
  methods: {
    async fetchDataById(id) {
      const result = await this.$API.borrow.borrowInfoById(id)
      this.borrower = result.data.borrowerDetailVO
      this.borrower.borrowerAttachVOList.forEach((item)=>{
        if(item.imageType==='idCard1'){
          this.image.idCard1 = item.imageUrl
        }else if(item.imageType==='idCard2'){
          this.image.idCard2 = item.imageUrl
        }else if(item.imageType==='house'){
          this.image.house = item.imageUrl
        }else if (item.imageType==='car'){
          this.image.car = item.imageUrl
        }
      })
    },
    async approveSubmit(){
      this.saveBtnDisabled = true
      this.borrowerApprove.borrowerId = this.$route.params.id
      const result = await this.$API.borrow.borrowApprove(this.borrowerApprove)
      if(result.code==200){
        this.$message.success(result.message)
        this.$router.push('/core/borrow/list')
      }
    }
  },
  mounted() {
    this.fetchDataById(this.$route.params.id)
  },
}
</script>

<style></style>
